<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:80:"D:\www\photo_albums_bless\public_html/../application/admin\view\button\edit.html";i:1544102029;s:69:"D:\www\photo_albums_bless\application\admin\view\lib\common_list.html";i:1543818465;}*/ ?>
<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:16:41 GMT -->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <title></title>

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/sys/css/style.min.css">
    <link rel="stylesheet" href="/static/plugins/bootstrap-table/bootstrap-table.css">
    <!--<link rel="stylesheet" href="/static/plugins/dataTables/dataTables.bootstrap.css">-->
    <link rel="stylesheet" href="/static/plugins/layer/skin/layer.css">
    <link rel="stylesheet" href="/static/plugins/layer/skin/layer.ext.css">
    <link rel="stylesheet" href="/static/plugins/layer/laydate/need/laydate.css">
    <link rel="stylesheet" href="/static/plugins/layer/laydate/skins/default/laydate.css">
    
    <script src="/static/plugins/jquery-1.12.4/jquery-1.12.4.min.js"></script>
    <script src="/static/plugins/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="/static/plugins/layer/layer.min.js"></script>
    <script src="/static/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/static/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/static/plugins/layer/laydate/laydate.js"></script>

    <style>
        .text-red{color:red;}
        .text-green{color:#17bb46;}
        .text-orange{color:orange;}
        .text-yellow{color:#c7cd2f;}
        .text-blue{color:#0bb8c8;}
        .fixed-table-toolbar .bars, .fixed-table-toolbar .columns, .fixed-table-toolbar .search{margin-top:-45px;}
        .th-inner{color:#555;}
    </style>
    
<link rel="stylesheet" type="text/css" href="/static/sys/css/common.css" />
<link rel="stylesheet" type="text/css" href="/static/plugins/select2/css/select2.css" />
<link rel="stylesheet" type="text/css" href="/static/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css" />

<link rel="stylesheet" type="text/css" href="/static/sys/css/skin_0.css" />
<style>
    .upfile i{padding-right:3px !important;}
    .file{ position:absolute;right:0;top:0;width:100px;height:100px;opacity:0; ilter:alpha(opacity=0);cursor:pointer;margin-bottom: 0px;margin-right: 0px; }
</style>

</head>

<body class="gray-bg">
    
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="post" id="fmNew" class="form-horizontal" enctype="multipart/form-data">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">按钮名称：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="name" value="<?php echo $Rs['name']; ?>" placeholder="请输入名称">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">按钮键名：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="key" value="<?php echo $Rs['key']; ?>" placeholder="请输入唯一的键名">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">按钮类型：</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="type_name" onchange="typeValue()">
                                    <option value="">请选择按钮类型...</option>
                                    <?php if(is_array($type_list) || $type_list instanceof \think\Collection || $type_list instanceof \think\Paginator): $i = 0; $__LIST__ = $type_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $v; ?>" type="<?php echo $key; ?>" <?php if(($key == $Rs['type'])): ?> selected <?php endif; ?>><?php echo $v; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div id="type_applet" hidden>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">小程序APP ID：</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="applet_app_id" name="applet_app_id" onchange="appletValue()">
                                        <?php if(is_array($applet_list) || $applet_list instanceof \think\Collection || $applet_list instanceof \think\Paginator): $i = 0; $__LIST__ = $applet_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
                                        <option value="<?php echo $v['app_id']; ?>" applet_path="<?php echo $v['applet_path']; ?>" applet_image="<?php echo $v['applet_image']; ?>" <?php if(($v['app_id']==$Rs['applet_app_id'])): ?> selected <?php endif; ?>><?php echo $v['app_id']; ?></option>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">小程序路径：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="applet_path" class="form-control" readonly name="applet_path" value="<?php echo $Rs['applet_path']; ?>" placeholder="请输入小程序路径">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">小程序跳转封面：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="applet_image" class="form-control" readonly name="applet_image" value="<?php echo $Rs['applet_image']; ?>" placeholder="请输入小程序跳转封面图">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div id="type_link" hidden>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">跳转链接：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="link" class="form-control" name="link" value="<?php echo $Rs['link']; ?>" placeholder="请输入跳转的网页链接">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">按钮图：</label>

                                <div class="col-sm-1">
                                <span id="button_img" class="btn btn-primary btn-sm" style="margin-bottom:0;padding:6px 8px;" onclick="chooseButton()">
                                    <i class="glyphicon glyphicon-folder-open" style="padding-right:3px;"></i> 按钮图<input type="hidden" name="image_url" id="image_url" value="<?php echo $Rs['image_url']; ?>" />
                                </span>
                                </div>
                                <div class="col-sm-1">
                                    <img id="previewImg_button" style="height:34px;float: right;" src="<?php echo $Rs['image_url']; ?>">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="status" id="status">
                                    <?php if(is_array($status_list) || $status_list instanceof \think\Collection || $status_list instanceof \think\Paginator): $i = 0; $__LIST__ = $status_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $key; ?>" <?php if(($key == $Rs['status'])): ?> selected <?php endif; ?>><?php echo $v; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">描叙：</label>
                            <div class="col-sm-8">
                                <textarea cols="100%" rows="3" name="desc"><?php echo $Rs['desc']; ?></textarea>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div id = 'hidden_input'>
                            <input type="hidden" id="type" name="type" value="<?php echo $Rs['type']; ?>"/>
                            <input type="hidden" id="id" name="id" value="<?php echo $Rs['id']; ?>"/>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-12 col-sm-offset-5">
                                <button class="btn btn-primary" id="ok" type="button">提交</button>
                                <button class="btn btn-white" id="cancel" type="button">取消</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
    
<script type="text/javascript" src="/static/plugins/select2/js/select2.js"></script>
<script type="text/javascript" src="/static/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="/static/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>

<script>
    $(document).ready(function () {
        $("#ok").bind("click", Save);
        $("#cancel").bind("click", function () {
            parent.layer.close(parent.layer_edit_index);
        });

        $('#applet_app_id').select2();

        // 初始化按钮类型
        var type = "<?php echo $Rs['type']; ?>";
        if (type == 'TYPE_APPLET') {
            $('#type_applet').show();
            var applet_app_id = "<?php echo $Rs['applet_app_id']; ?>";
            //$('#applet_app_id').val(applet_app_id);
        } else {
            $('#type_link').show();
        }

        /**
         * 保存内容
         */
        function Save() {
            var load_index = layer.load(0, { shade: false });

            $.ajax({
                type: 'POST',
                url: "<?php echo url('button/edit'); ?>",
                data: $("#fmNew").serialize(),
                dataType: 'json',
                success: function (data) {
                    if (data.code == 1) {
                        layer.close(load_index);
                        layer.alert(data.msg, function () {
                            parent.refreshtb();
                            //window.close();
                            parent.layer.close(parent.layer_edit_index);
                        });
                    } else {
                        layer.alert(data.msg);
                    }
                }
            })
        }

        // 时间插件
        $('.form_datetime').datetimepicker({
            weekStart: 0, //一周从哪一天开始
            todayBtn:  1, //
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            //showMeridian: 1,
            language:'zh-CN',
            format: 'yyyy-mm-dd',
            minView:'month',
        });

    });

    function chooseButton() {
        layer_chose_index = layer.open({
            type: 2,
            title: "选择图片",
            area: ['90%', '90%'],
            content: "<?php echo url('selection/image'); ?>?tag=button_img",
        })
    }

    // 显示选择的图片，跨域选中图片的回调函数
    function get_selected_img(res) {
        if (res.tag == 'button_img') {
            $('#button_img').val(res.image_url);
            $('#previewImg_button').attr('src', res.image_url);
        }

    }

    function typeValue() {
        var type = $("#type_name").children('option:selected').attr('type');
        $('#type').val(type);
        if (type == 'TYPE_APPLET') {
            $('#type_applet').show();
            $('#type_link').hide();
            $('#link').val('');
            $('#image_url').val('');
            $('#previewImg_button').attr('src', '');
        } else if (type == 'TYPE_LINK') {
            $('#type_link').show();
            $('#type_applet').hide();
            $('#applet_app_id').val('');
            $('#applet_path').val('');
            $('#applet_image').val('');
        }
    }

    function appletValue() {
        var applet_path = $('#applet_app_id').children('option:selected').attr('applet_path');
        var applet_image = $('#applet_app_id').children('option:selected').attr('applet_image');
        $('#applet_path').val(applet_path);
        $('#applet_image').val(applet_image);
    }

</script>

<!-- Mirrored from www.zi-han.net/theme/hplus/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:17:11 GMT -->
</html>
